package websocket;

import org.java_websocket.WebSocket;
import websocket.client.MyWebSocketClient;

import java.net.URI;
import java.net.URISyntaxException;

/**
 * @Author: shrek
 * @Date: 2020/7/4 21:27
 * @Description:
 */
public class DemoApplication {

    public static void main(String[] args) throws InterruptedException {
        URI uri = null;
        try {
            uri = new URI("ws://localhost:8080/websocket");
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
        MyWebSocketClient client = new MyWebSocketClient(uri);
        client.connect();
        //logger.info(client.getDraft());
        while(!client.getReadyState().equals(WebSocket.READYSTATE.OPEN)){
            System.out.println("正在连接...");
        }
        //连接成功,发送信息
        client.send("哈喽,连接一下啊");
        // 往websocket服务端发送数据
        client.send("此为要发送的数据内容");

    }
}